const express = require('express');
const router = express.Router();
const { protect } = require('../middlewares/auth');
const groupController = require('../controllers/groupController');

// 群组管理
router.post('/', protect, groupController.createGroup);
router.get('/', protect, groupController.getUserGroups);
router.get('/code/:groupCode', protect, groupController.findGroupByCode);
router.get('/invitations', protect, groupController.getPendingGroupInvitations);
router.put('/invitations/:invitationId', protect, groupController.respondToGroupInvitation);
router.get('/:groupId', protect, groupController.getGroupById);
router.get('/:groupId/permissions', protect, groupController.getUserGroupPermissions);
router.put('/:groupId', protect, groupController.updateGroupInfo);
router.delete('/:groupId', protect, groupController.deleteGroup);

// 群组成员管理
router.post('/:groupId/invite', protect, groupController.inviteToGroup);
router.post('/:groupId/join', protect, groupController.requestJoinGroup);
router.get('/:groupId/join-requests', protect, groupController.getPendingJoinRequests);
router.put('/:groupId/join-requests/:requestId', protect, groupController.respondToJoinRequest);
router.post('/:groupId/leave', protect, groupController.leaveGroup);
router.put('/:groupId/members/:userId', protect, groupController.manageGroupMember);

module.exports = router; 